package com.example.baiduocr;


import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Base64;

public class RR {


    public static void convertBase64ToExcel(String base64String, String outputFilePath) throws IOException {
        // 1. 解码Base64字符串
        byte[] decodedBytes = Base64.getDecoder().decode(base64String);

        // 2. 创建Excel工作簿
        try (Workbook workbook = new XSSFWorkbook();
             FileOutputStream fos = new FileOutputStream(outputFilePath)) {

            // 3. 创建工作表
            Sheet sheet = workbook.createSheet("Sheet1");

            // 4. 如果是CSV格式的Base64，可以这样处理
            String csvContent = new String(decodedBytes);
            String[] lines = csvContent.split("\n");

            for (int i = 0; i < lines.length; i++) {
                Row row = sheet.createRow(i);
                String[] columns = lines[i].split(",");

                for (int j = 0; j < columns.length; j++) {
                    Cell cell = row.createCell(j);
                    cell.setCellValue(columns[j]);
                }
            }

            // 5. 写入Excel文件
            workbook.write(fos);
        }
    }

    public static void main(String[] args) {
        try {
            // 示例Base64字符串（实际使用时替换为你的Base64）
            String base64Excel = "UEsDBBQACAgIAGyd/FoAAAAAAAAAAAAAAAALAAAAX3JlbHMvLnJlbHOtksFKAzEQhl8lzL2bbQURadqLCL2J1AcYk9ndsJtMSEbdvr3Bi7ZsQcHjMDPf/zHJdj+HSb1TLp6jgXXTgqJo2fnYG3g5Pq7uQBXB6HDiSAZOVGC/2z7ThFJXyuBTUZURi4FBJN1rXexAAUvDiWLtdJwDSi1zrxPaEXvSm7a91fknA86Z6uAM5INbgzpi7kkMzJP+4Dy+Mo9NxdbGKdFvQrnrvKUHtm+BoixkX0yAXnbZfLs4tk+Z6yam9N8yNAtFR26VagJl8fXiV4xuFowsZ/qb0vVH0YEEHQp+US+E9Nkf2H0CUEsHCG4yCEvlAAAASgIAAFBLAwQUAAgICABsnfxaAAAAAAAAAAAAAAAAEwAAAFtDb250ZW50X1R5cGVzXS54bWy1U8tuwjAQ/JXI1yo29FBVFYFDH8cWqfQDXHuTWPglr6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WAgAABAcAABQAAAAAAAAAAAAAAAAArwQAAHhsL3NoYXJlZFN0cmluZ3MueG1sUEsBAhQAFAAICAgAbJ38WhPnVKgcAwAAYicAAA0AAAAAAAAAAAAAAAAABwcAAHhsL3N0eWxlcy54bWxQSwECFAAUAAgICABsnfxasNnU6tkAAABdAQAADwAAAAAAAAAAAAAAAABeCgAAeGwvd29ya2Jvb2sueG1sUEsBAhQAFAAICAgAbJ38WmfroqjVAAAANAIAABoAAAAAAAAAAAAAAAAAdAsAAHhsL19yZWxzL3dvcmtib29rLnhtbC5yZWxzUEsBAhQAFAAICAgAbJ38WrmnqXKZBgAAfzkAABgAAAAAAAAAAAAAAAAAkQwAAHhsL3dvcmtzaGVldHMvc2hlZXQxLnhtbFBLBQYAAAAACQAJAD8CAABwEwAAAAA=";
            convertBase64ToExcel(base64Excel, "output.xlsx");
            System.out.println("Excel文件生成成功！");
        } catch (IOException e) {
            System.err.println("转换失败: " + e.getMessage());
        }
    }
}

